Okay.
So welcome to the last lecture then on this speed simulator.
So this is where we're going to finish off.
We've got a couple.
Well two two main additions I want to make today.
The first one is a little visual effect when you are walking.
And the second is a help NPC just to give the player some guidance if they are completely new to the
game.
So um, the um, walking, um, visual effect I'm looking at here is called the FOV.
Um, oh.
An issue here.
Um, what's the issue with this?
Hmm.
That's strange.
Some reason got rid of shop items.
Items.
It's equal to open open open open bracket.
Close bracket.
That's strange.
I must have done accidentally when I was looking through things.
Um, so I don't believe that's a mistake I made, um, during the lecture.
But if it is, if it is, that's that's it.
That's up to correct.
And yeah, it works fine now.
Anyway, so what I was talking about there is before I got interrupted by the error is about camera
FOV.
So camera FOV is actually quite important.
Um, and it can give all kind of cool visual effects really.
So the camera FOV is also pretty pretty easy to change.
Go over to workspace, go over to your character model, go over to the humanoid and FOV is somewhere
in amongst all these properties here I believe.
Um.
Oh, no, it wouldn't be.
So what am I talking about?
No, it's not going to be in the in the character, is it.
Because it's not.
It's the current camera here.
So the camera object field of view is is a property here.
And this is using a lot of games.
Field of view is basically the angle um that you can see for in 60 would be a whole like um 360 view,
which would be quite cool.
But um, not really possible for games.
Um, this allows has a certain, a certain range that you can put it on.
70 is the default, but we can change this to be 80, for example.
And it goes out a bit 70 back in a bit.
And that's kind of what, that's kind of what I want to do.
I want to increase this to about 80 just to like, because when you're sprinting, it's a good idea
to increase this.
When you're sprinting, it gives a bit more of a visual effect that you are actually sprinting, which
I thought was just a cool addition really to make to our game.
And also we can use to services user input service and tween service, which which we wouldn't have
otherwise used in this game, which I think is quite cool.
So I'm going to close all these.
I'm going to go into starter player and add a script into our local script inside of starter player
scripts.
Okay, difference between these.
Anything in starter character scripts goes into into the character to start off with, and anything
can start a player scripts goes into the player to start off with.
This isn't really anything to do with the physical objects and stuff, so I'm going to be putting it
into starter player scripts.
I'm going to call this camera FOV.
Okay, so let's first fetch user input service and tween service.
Now if you have been following this course in order, um, we did this right at the start of this advanced
scripting section.
So it's been a while.
Um, but yeah.
So user it'll be good.
Um, good.
Recap use input service is equal to game get service user input service and then local tween service.
Is equal to game get service.
Tween service Y.
Tween service.
Well, if we just jumped for FOV from 70 to 80 and then when he finished scripting back to 70, it would
look really ugly.
Okay.
I wanted to kind of fade in and fade out, which would give a much better view overall.
Okay, we also need the player which will be the local player game, dot players, dot local player,
and then also um, the camera listed there which will be game dot workspace, dot current camera is
how you reference that one.
Um onwards we have got um what we need to put down the tween info.
So between now because we can we could create the information between later on, but because between
info can be used for both in and out tween, it makes more sense to create it now rather than create
it twice later on.
So local f.of tween info I'm going to call it is equal to tween info dot new.
And to make it simpler I'm going to put this um, let's lay this out like this.
So over time I'm going to put to be 0.2 seconds a very quick animation, but just enough so that it's
not a jump.
You can see it go in and out.
Um, I put a comma.
Yeah.
The easing style is just going to be linear.
Um, so enum dot easing style dot linear.
And you use linear a lot more than you might thought you would do to start off with.
Really it's one of the one of the common types, the most common in type when we use when we use tween
service, ease and direction is going to be it doesn't matter too much really, but I'm going to put
it in out.
Um, we count zero only going to work when we want, once when we want it to work, reverses is going
to be false.
Now, I understand the term the FOV is going to go out and back in, but what what what reverses allows
it to do is to go out and then immediately go back in.
That's not what we want for this, because we want it to go out as soon as they start sprinting.
And in once they finish sprinting, we'd know how long that's going to be.
It's not going to be instant, so we can't use reverses for that and then delay time zero.
It's immediate to we wanted to start cool.
So if you remember use input Service for two main events we use are input began and input ended.
They're the ones that we're using for this.
So use input service dot input began.
Connect with our function.
And we have our input and our game processed events like that there.
So we're going to use input use input service.
Basically detect when they use the W, A, S or D keys if they press any of these.
We know that they are going to be, well, walking.
And then when they un press any of these, we know they've stopped walking.
So we're also going to need the input ended event as well.
Which means I'll just copy and paste this down here for input ended.
So we first need to check that the type here is of a keyboard.
So if input.
Input dot user input type is equal to enum dot user input type dot keyboard.
And I'm also going to check here and not game process event.
It's a good idea to check this now and not later on is because if it is a game process event, it's
running less code.
It's not then checking a whole another set of conditions.
We're going to stop it immediately.
If it's not a game processed event, remember it's a game processed event when something else like a
GUI or a chat, um, cause it caused this input to occur.
Let's then check if it's of the correct key codes.
So input dot key code is equal to enum dot key code dot.
And there's four bonding check w a, s and d.
So we're going to have to put repeat this a couple times with a different keys.
So for W.
For S.
For a.
Or for.
Cool.
And if it's any of those, we want to make the fog go out.
This is when they start sprinting, so it needs to go out from 72.
I think putting is 80 the best bet, but you can play around with that if you'd like to adjust it.
So twin service colon create to create our tween.
We're going to reference the camera as the instance between information we've already got above.
And then the property table will just be a table saying field.
Of view is equal to 70 like that.
There play that.
And that's pretty much it.
Okay.
So we can kind of copy this for the other section really.
Um, as we're checking the same kind of things.
Only difference is this will be um moving up to no sorry.
This is going to be moving its 80.
It's currently 70.
We want to move it to 80.
And this one, once it's finished we're going to.
Move it back back down to 70.
So let's play the game and see how it's kind of affects it.
Um I think it just gives gives a lot more um, a bit more detail to it I think.
Um, so we start running and we can see it, of course, not moving that fast and then it stops like
that there.
So I think it just adds a nice bit of detail to the game really, I think, um.
And kind of makes you feel like you're actually going fast if was moving fast.
Um, but yeah, just a cool addition.
I think we could have made their cool.
And then the final bit is just to add like a help NPC, really, just so that if any players are new,
there's someone guiding them on what to do.
So for this, I'm going to go over to the workspace and I'm actually going to add one in using a plugin.
Up here I have there's a couple plugins I have actually which insert characters.
I'm going to use the one from Moon Animator two, but it's also the character insert which is free.
I'm going to add myself in here, um, but feel free to add whatever character that you would like.
I'm going to make sure when this is laid out, that it's relatively close to where I lock on to much,
relatively close to where the player spawns in.
There's no point if this is all the way over there, because it'll take half an hour to walk there.
So let's just see how far this is away.
Don't mind them walking too much towards it, but just um.
So that's perfect there.
Really?
Um, maybe just rotating it and moving it a bit more to the left or right might be the best idea there.
Um, so it's like here.
So let's rotate it and move it over to the right like that.
There.
Maybe even rotate it a bit more like that.
Just facing it.
But yeah okay, cool.
So we're going to use the dialogue which you looked at in the more advanced topics really.
So dialogue is going to go inside the player's head.
So let's add in a dialogue.
And this is going to just have a bit of a conversation.
You know who are you.
What's the game goal of a game.
How can we gain speed.
Stuff like that.
Um so the initial prompt is going to be um, we initial prompt is um, chat message that it displayed
to the player when they first activate the dialogue.
Um, so we're going to say, hey, um.
Just.
Hey.
Really?
Um.
That would be fine.
Goodbye.
Dialog is displayed.
Um, when you want to exit the dialog.
So.
By like that.
Their help and toe neutral are all fine.
Um, and that will be pretty much it.
So at the moment, it's just it's just going to say hey and goodbye.
But if we add in some dialogue choices, we can adjust some of these.
So I want to one I'm going to write up a couple here, but feel free to change this based on what you
want your character to say.
All of the goodbye dialogues are going to be bye.
Um, but yeah.
Okay, so the user dialogue for the first one I'm going to say is, um, who are you?
And I'm going to say, um, I am the.
Creator of this game.
As it is my character.
Um, second one.
This one I'm going to I'm going to say, why am I so slow?
And you said you.
Built.
Up speed the more you walk.
Okay.
And um, let's say also, um, what are the items of.
Sorry?
Um, what are the items?
In the shop.
For.
And then say, um, can make.
You even faster.
But have a cool down and, um, anything else?
I'm trying to think.
Not really.
Um, I think that's pretty much it, to be honest.
One of my thing is, well, I think the setting is to be a hundred to start off with isn't the best
idea because, um, when before it's before the speed value changes zero.
It's classes a hundred.
So I'm going to change this here.
So that's display display frame um speed.
Frame text label just to be zero as the default value.
And let's play the game.
As our final finished product.
Really?
So we're starting off at zero.
That's quite nice.
We can go over to here.
Hey, who are you?
Why am I so slow?
What items are there in the shop and then buy?
So why am I so slow?
You'll build up the more speed you walk.
So it gives you gives a player if they're a bit stuck a bit, some prompts basically.
And what to do with the game?
I just noticed I've got a question mark on one of those to change.
Um, create or not create.
Creator.
Um.
Did you not like question marks?
Who are you?
Why am I so slow?
We must know.
I'm.
Maybe I'm I don't know.
I thought it didn't contain any question, but maybe it did, I don't know.
Anyway, um, so that is as far as we're going to go in this tutorial now.
Um, I'll be honest, my original plan.
Um, was to add some more things as well.
Um, so in the shop, I also actually wanted to create different sections of the shop, um, one for
effects, which might like double the amount of the amount of speed you get by walking or, you know,
make you, um, make the cooldown on items less, for example, as well as some trails, some game passes,
and maybe even some pets as well.
Um, but the code got a bit too much I think.
Um, for it learning of making your first proper game.
It was a very repetitive code because, um, for items you display their cooldown, whereas effects
and trails don't have cooldown.
So you have to edit your code.
Yeah, the penal code four times for these different things, but edit them slightly, just so much
that it becomes very difficult to just like put a full comma in there and repeat it four times.
So some other things I had an idea of making a leaderboards, um, like starting area on the map.
So like a little town or something like that in the map somewhere and stuff like that.
But um, this, this tutorial has already been quite long and don't want to make it too much longer.
And I think I've already shown quite a bit of the things that I have that we've looked at in the last
two sections, but I think this is really where you should take this, you should take this, take it
from here, basically, as I also think it's important that, um, now, you know, you're getting towards
the end of this, um, this course, some of the things you might not have done is, um, kind of work
on things by yourself, almost.
You know, I've been guiding you for a lot of these things.
It's a very important as well, that you're able to fix some of the errors that come up yourself, you
know, where do you go to fix these errors?
Um, a bit of perseverance and things like that.
So I think it's a really good chance really for you to get to that.
So if you are a bit stuck on what other things to add, I would recommend maybe adding in some trails
or some pets, which is very similar.
Shop to what we're coded here so you shouldn't have too much.
Any issues coding in the shop and setting up the trails and stuff, you know, structures and constraints.
Um, but yeah, or maybe a leaderboard.
We can you can use messaging service for that, um, build maybe a little like starting area here.
I didn't make one because we didn't really look at building in the last two sections and don't want
to spend a lesson building up building the town.
When we did that right at the start, you know, um, and some other stuff really.
But I think this game as it is, is a complete product of a game.
There's just the more things you can add on with any game, there's always more and more stuff you can
add on.
But, um, I kind of want to leave it, leave it here because I don't want this to be like a, um,
ten hour long thing on how to how to make this game.
Um, so absolutely take it from here.
Um, and yeah, it was good, good like idea to, um, kind of unleash your creativity, I guess, on
this.
Um, feel free to add other things that I didn't suggest as well, but I hope you enjoyed this section
of the course.
And that is the main chunk of the course over with.
I mean, if you are watching this, um, in, in the, um, in the order it was recorded.
Well done.
You've made it pretty far.
Um, next we've got the blender section, which I think is extremely important for game development.
Um, then there's just some smaller sections on advertising and things like that, and we're done.
So I'm hope you're enjoying hope you've enjoyed the course so far.
We've got a little bit more to go and yeah, that that'll be it.
So yeah again hope you've enjoyed this.
And I will um looking forward to join you in the next section.
But you choose to go to next.